/**
 * @description 路由配置文件
*/

// const router = {
//   routes: [
//     {
//       path: '/ox/demo', // 示例
//       controller: DemoController,
//       children: [
//         {
//           path: 'list', // 示例列表
//           method: 'get',
//           action: 'queryAll'
//         }
//       ]
//     }
//   ]
// }
/* 自定义控制器 */
// 仅本地增、删、改
let permission = {
  // hosts: 'localhost',
  rules: ['admin']
}

const router = {
  routes: [
    {
      path: '/server/user',
      controller: require('../modules/user/controller.js'),
      children: [
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            operators: [
              {field: 'id', operator: 'EQUAL'},
              {field: 'phoneNumber', operator: 'LIKE'},
              {field: 'sex', operator: 'EQUAL'},
              {field: 'nickName', operator: 'LIKE'},
              {field: 'userType', operator: 'IN'},
              {field: 'roleId', operator: 'IN'},
              {field: 'deptId', operator: 'IN'},
              {field: 'isDelete', operator: 'EQUAL'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            limit: {
              pageSize: {field: 'pageSize', default: 10},
              pageIndex: {field: 'pageIndex', default: 1}
            }
          }
        },
        {
          path: 'list/all',
          method: 'get',
          action: 'queryAll',
          excute: {
            operators: [
              {field: 'id', operator: 'EQUAL'},
              {field: 'phoneNumber', operator: 'LIKE'},
              {field: 'sex', operator: 'EQUAL'},
              {field: 'nickName', operator: 'LIKE'},
              {field: 'userType', operator: 'IN'},
              {field: 'roleId', operator: 'IN'},
              {field: 'deptId', operator: 'IN'},
              {field: 'isDelete', operator: 'EQUAL'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            sort: [
              {field: 'createTime', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        }
      ]
    }
  ]
}

module.exports = router